package trace

import (
	v1 "code.byted.org/bytertc/whiteboard_server/biz/api/pb/v1"
)

const INTERNAL = "internal"

// span name
const (
	RtmUnicast   = `rtm.unicast`
	RtmBroadcast = `rtm.broadcast`

	CmdGetBoardInfo   = `cmd.board_info`
	CmdEditing        = `cmd.editing`
	CmdHeartBeat      = `cmd.heartbeat`
	CmdGetActionCount = `cmd.action_count`
	CmdGetSnapshot    = `cmd.snapshot`
	CmdCreateBoard    = `cmd.create_board`
	CmdUnimplemented  = `cmd.unimplemented`

	EditingDraw        = `editing.draw`
	EditingErase       = `editing.erase`
	EditingSubErase    = `editing.sub_erase`
	EditingChangeAudio = `editing.change_audio`
	EditingChangeVideo = `editing.change_video`

	Compact       = `compact`
	CompactUpload = `compact.upload`

	StartWebCast = `rtcapi.startwebcast`
	StopWebCast  = `rtcapi.stopwebcast`
	StartRecord  = `rtcapi.startrecord`
	StopRecord   = `rtcapi.stoprecord`
)

var commandTraceName = map[v1.Command]string{
	v1.Command_kGetBoardInfo:     CmdGetBoardInfo,
	v1.Command_kEditing:          CmdEditing,
	v1.Command_kHeartBeat:        CmdHeartBeat,
	v1.Command_kGetActionCount:   CmdGetActionCount,
	v1.Command_kGetShapeSnapshot: CmdGetSnapshot,
	v1.Command_kCreateBoard:      CmdCreateBoard,
}

func CommandTraceName(command v1.Command) string {
	str, ok := commandTraceName[command]
	if !ok {
		str = CmdUnimplemented
	}
	return str
}

// tag name
const (
	IsError    = `_is_error`
	BucketName = `bucket`
	DataLength = `data_len`
)

const EventTypeBiz = `biz`
const EventTypeAction = "action"

//go:generate stringer -type=Event -output=consts_string.go
type Event int

const (
	ActionNew Event = iota
	ActionFinished
	ActionConflict
	HandleRTM
)
